﻿namespace PMS.Client.FrmRoleMenu
{
    using PMS.BLL;
    using PMS.Model;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class FrmAdd : Form
    {
        private Button btnCancel;
        private Button btnSave;
        private IContainer components = null;
        private Label label1;
        private TextBox RoleName;

        public FrmAdd()
        {
            this.InitializeComponent();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            base.Close();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.RoleName.Text.Trim() != "")
            {
                Role role2 = new Role {
                    RoleName = this.RoleName.Text.Trim()
                };
                Role model = role2;
                if (new RoleBLL().Add(model) > 0)
                {
                    SyslogBLL.Write("角色添加", "角色" + this.RoleName.Text + "添加成功");
                    base.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("添加失败！");
                }
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(FrmAdd));
            this.btnCancel = new Button();
            this.btnSave = new Button();
            this.RoleName = new TextBox();
            this.label1 = new Label();
            base.SuspendLayout();
            this.btnCancel.BackColor = Color.White;
            this.btnCancel.FlatStyle = FlatStyle.Popup;
            this.btnCancel.Location = new Point(0xcb, 0x58);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new Size(0x4b, 0x17);
            this.btnCancel.TabIndex = 0x16;
            this.btnCancel.Text = "取消";
            this.btnCancel.UseVisualStyleBackColor = false;
            this.btnCancel.Click += new EventHandler(this.btnCancel_Click);
            this.btnSave.BackColor = Color.White;
            this.btnSave.FlatStyle = FlatStyle.Popup;
            this.btnSave.Location = new Point(0x56, 0x58);
            this.btnSave.Name = "btnSave";
            this.btnSave.Size = new Size(0x4b, 0x17);
            this.btnSave.TabIndex = 0x15;
            this.btnSave.Text = "保存";
            this.btnSave.UseVisualStyleBackColor = false;
            this.btnSave.Click += new EventHandler(this.btnSave_Click);
            this.RoleName.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.RoleName.BorderStyle = BorderStyle.FixedSingle;
            this.RoleName.Location = new Point(0x56, 0x25);
            this.RoleName.Name = "RoleName";
            this.RoleName.Size = new Size(0xc0, 0x15);
            this.RoleName.TabIndex = 20;
            this.label1.AutoSize = true;
            this.label1.Location = new Point(0x1b, 0x27);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x35, 12);
            this.label1.TabIndex = 0x13;
            this.label1.Text = "角色名称";
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = AutoScaleMode.Font;
            this.BackColor = Color.FromArgb(0xa4, 0xc4, 0xeb);
            base.ClientSize = new Size(0x14d, 140);
            base.Controls.Add(this.btnCancel);
            base.Controls.Add(this.btnSave);
            base.Controls.Add(this.RoleName);
            base.Controls.Add(this.label1);
            base.FormBorderStyle = FormBorderStyle.FixedSingle;
            base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "FrmAdd";
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "添加角色";
            base.ResumeLayout(false);
            base.PerformLayout();
        }
    }
}

